<template>
  <div>
    <div class="container radiusBottom">
      <div class="images">
        <div class="img">
          <img :src="styleUrls[dataJson.type][dataJson.stylesType]" />
        </div>
        <div class="buttonSetStyle" @click="alertTag">修改样式</div>
      </div>
    </div>
    <div class="container">
      <div class="title">
        底部导航
        <strong class="pull_right">建议尺寸：100px*100px</strong>
      </div>
      <div class="line">
        <div class="left">
          <div class="tabBar-img">
            <img
              :src="dataJson.imgUrls[0].src"
              class="tabBar-imgs"
              @click="showdialog(0, '底部导航')"
            />
          </div>
        </div>
        <div class="inputContent line-heiht_60">
          <el-input
            v-model="dataJson.imgUrls[0].substance"
            class="inputs"
            type="text"
            maxlength="5"
          />
        </div>
        <el-tooltip
          class="right_btn"
          effect="dark"
          :content="dataJson.imgUrls[0].jump_name"
          placement="bottom"
        >
          <el-button
            type="text"
            class="buttonText"
            @click="chooseLink(0), (alertLinkName = 'tabbar')"
          >
            {{
              dataJson.imgUrls[0].jump_name
                ? dataJson.imgUrls[0].jump_name
                : "选择链接"
            }}
          </el-button>
        </el-tooltip>
      </div>

      <div class="line">
        <div class="left">
          <div class="tabBar-img">
            <img
              :src="dataJson.imgUrls[1].src"
              class="tabBar-imgs"
              @click="showdialog(1, '底部导航')"
            />
          </div>
        </div>
        <div class="inputContent line-heiht_60">
          <el-input
            v-model="dataJson.imgUrls[1].substance"
            class="inputs"
            type="text"
            maxlength="5"
          />
        </div>
        <el-tooltip
          class="right_btn"
          effect="dark"
          :content="dataJson.imgUrls[1].jump_name"
          placement="bottom"
        >
          <el-button
            type="text"
            class="buttonText"
            @click="chooseLink(1), (alertLinkName = 'tabbar')"
          >
            {{
              dataJson.imgUrls[1].jump_name
                ? dataJson.imgUrls[1].jump_name
                : "选择链接"
            }}
          </el-button>
        </el-tooltip>
      </div>
      <div class="line">
        <div class="left">
          <div class="tabBar-img">
            <img
              :src="dataJson.imgUrls[2].src"
              class="tabBar-imgs"
              @click="showdialog(2, '底部导航')"
            />
          </div>
        </div>
        <div class="inputContent line-heiht_60">
          <el-input
            v-model="dataJson.imgUrls[2].substance"
            class="inputs"
            type="text"
            maxlength="5"
          />
        </div>
        <el-tooltip
          class="right_btn"
          effect="dark"
          :content="dataJson.imgUrls[2].jump_name"
          placement="bottom"
        >
          <el-button
            type="text"
            class="buttonText"
            @click="chooseLink(2), (alertLinkName = 'tabbar')"
          >
            {{
              dataJson.imgUrls[2].jump_name
                ? dataJson.imgUrls[2].jump_name
                : "选择链接"
            }}
          </el-button>
        </el-tooltip>
      </div>

      <div
        v-if="dataJson.stylesType == 1 || dataJson.stylesType == 0"
        class="line"
      >
        <div class="left">
          <div class="tabBar-img">
            <img
              :src="dataJson.imgUrls[3].src"
              class="tabBar-imgs"
              @click="showdialog(3, '底部导航')"
            />
          </div>
        </div>
        <div class="inputContent line-heiht_60">
          <el-input
            v-model="dataJson.imgUrls[3].substance"
            class="inputs"
            type="text"
            maxlength="5"
          />
        </div>
        <el-tooltip
          class="right_btn"
          effect="dark"
          :content="dataJson.imgUrls[3].jump_name"
          placement="bottom"
        >
          <el-button
            type="text"
            class="buttonText"
            @click="chooseLink(3), (alertLinkName = 'tabbar')"
          >
            {{
              dataJson.imgUrls[3].jump_name
                ? dataJson.imgUrls[3].jump_name
                : "选择链接"
            }}
          </el-button>
        </el-tooltip>
      </div>
      <div v-if="dataJson.stylesType == 0" class="line">
        <div class="left">
          <div class="tabBar-img">
            <img
              :src="dataJson.imgUrls[4].src"
              class="tabBar-imgs"
              @click="showdialog(4, '底部导航')"
            />
          </div>
        </div>
        <div class="inputContent line-heiht_60">
          <el-input
            v-model="dataJson.imgUrls[4].substance"
            class="inputs"
            type="text"
            maxlength="5"
          />
        </div>
        <el-tooltip
          class="right_btn"
          effect="dark"
          :content="dataJson.imgUrls[4].jump_name"
          placement="bottom"
        >
          <el-button
            type="text"
            class="buttonText"
            @click="chooseLink(4), (alertLinkName = 'tabbar')"
          >
            {{
              dataJson.imgUrls[4].jump_name
                ? dataJson.imgUrls[4].jump_name
                : "选择链接"
            }}
          </el-button>
        </el-tooltip>
      </div>
    </div>
    <navAlert :nav="nav" @closeNav="nav = false" @navTag="navTag" />
  </div>
</template>

<script>
import { styleUrls } from "../../data";
export default {
  components: {
    navAlert: () => import("./toolCom/navAlert")
  },
  props: {
    dataJson: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      styleUrls,
      nav: false,
      idx: -1
    };
  },
  methods: {
    alertTag() {
      this.$emit("alertTag", true, this.dataJson.stylesType, 29);
    },
    chooseLink(index) {
      this.$emit("chooseLink", index);
    },
    showdialog(index) {
      this.nav = true;
      this.idx = index;
    },
    navTag(e) {
      this.dataJson.imgUrls[this.idx].src = e[0].src;
    }
  }
};
</script>

<style lang="scss" scoped>
@import "~@/assets/scss/decorate.scss";
</style>
